package com.itheima;

import java.util.HashMap;
import java.util.Map;

public class MapPractice {
    public static void main(String[] args) {
        Map<String,String>data=new HashMap<>();
        data.put("小王1","A");
        data.put("小王2","B");
        data.put("小王3","C");
        data.put("小王4","D");
        data.put("小王5","B");
        data.put("小王56","D");
        data.put("小王6","D");
        data.put("小王67","A");
count(data);    }

    public static void count(Map<String,String>data){
        Map<String,Integer>resultMap=new HashMap<>();
        data.forEach((k,v)->{

            boolean containKey=resultMap.containsKey(v);
            if(containKey){
                Integer oldCount=resultMap.get(v);
                resultMap.put(v,oldCount+1);
            }else{
                resultMap.put(v,1);
            }
        });
        resultMap.forEach((k,v)-> System.out.println(k+"----"+v));

    }
}
